<?php
/* SVN FILE: $Id: courses_controller.php 17 2009-09-27 01:49:33Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-27 01:49:33 +0000 (Sun, 27 Sep 2009) $
 * $Revision: 17 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/controllers/courses_controller.php $
 */
class CoursesController extends AppController
{
  var $name = 'Courses';
  var $uses = array('Course','User');
  var $scaffold = 'admin';
  
  function index()
  {
    $courselist = $this->Course->listForUser($this->Session->read('Auth.User.id'));

    if (count($courselist) == 0)
    {
      $this->set('courses',array());    
    }
    else if (count($courselist) == 1)
    {
      $this->redirect('/assignments/index/' . $courselist[0]['courses']['id']); 
    }
    else
    {
      $this->set('courses',$courselist);
    }
  }
}
?>